package com.zheng.flink.study.dataset.transformation;

import lombok.extern.slf4j.Slf4j;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.functions.KeySelector;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhengbo
 * @date 2019/12/12
 */
@Slf4j
public class MapTransformation {

    public static void main(String[] args) throws Exception {

        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

        List<Integer> collection = new ArrayList<>();
        collection.add(1);
        collection.add(2);
        collection.add(3);
        collection.add(4);

        env.fromCollection(collection).map(new MapFunction<Integer, Integer>() {
            @Override
            public Integer map(Integer value) throws Exception {
                log.info("execute map:{}", value);
                return value * 2;
            }
        }).print();

    }
}
